home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / optimr.zip / OPTIMER.ASM < prev    next >
Assembly Source File  |  1988-08-15  |  923b  |  34 lines

  1. cli             ;Disable interrupts
  2. mov  dx,$20     ;Address PIC ocw3
  3. mov  al,$0A     ;Ask to read irr
  4. out  dx,al
  5. mov  al,$00     ;Latch timer 0
  6. out  $43,al
  7. in   al,dx      ;Read irr
  8. mov  di,ax      ;Save it in DI
  9. in   al,$40     ;Counter --> bx
  10. mov  bl,al      ;LSB in BL
  11. in   al,$40
  12. mov  bh,al      ;MSB in BH
  13. not  bx         ;Need ascending counter
  14. in   al,$21     ;Read PIC imr
  15. mov  si,ax      ;Save it in SI
  16. mov  al,$0FF    ;Mask all interrupts
  17. out  $21,al
  18. mov  ax,$40     ;read low word of time
  19. mov  es,ax      ;from BIOS data area
  20. es:
  21. mov  dx,[$6C]
  22. mov  ax,si      ;Restore imr from SI
  23. out  $21,al
  24. sti             ;Enable interrupts
  25. mov  ax,di      ;Retrieve old irr
  26. test al,$01     ;Counter hit 0?
  27. jz   done       ;Jump if not
  28. cmp  bx,$FF     ;Counter > $FF?
  29. ja   done       ;Done if so
  30. inc  dx         ;Else count int req.
  31. done:
  32. mov [bp-4],bx   ;set function result
  33. mov [bp-2],dx
  34.